package Client;

import java.sql.*;
import java.util.*;

@SuppressWarnings("unused")

public class GetNumberOfTable {

	public void www() {

		bianliang h = new bianliang();
		Connection con = null;
		Statement sql;
		ResultSet rs;
		ResultSet zs;
		try {
			Class.forName("org.mariadb.jdbc.Driver");
		} catch (Exception e) {
			System.out.println(e);
		}

		String uri = "jdbc:mariadb://localhost:3306/login_word";
		String user = "test";
		String password = "123";

		try {
			con = DriverManager.getConnection(uri, user, password); // 连接代码
		} catch (Exception e) {
			System.out.println(e);
		}

		try {
			sql = con.createStatement();

			String command1 = "show tables";
			rs = sql.executeQuery(command1);
			rs.last();
			h.Last = rs.getRow();
			char[][] c = new char[h.Last][];
			int[] m = new int[h.Last];

			rs.beforeFirst();
			zs = sql.executeQuery(command1);

			for (int i = 0; i < h.Last; i++) {
				rs.next();
				String ss = rs.getString(1);

				m[i] = ss.length();
				c[i] = new char[9];
				for (int k = 0; k < m[i]; k++) {
					c[i][k] = ss.charAt(k);
				}

			}

			for (int f = 0; f < h.Last; f++) {
				for (int w = 1; w < c[f].length; w++) {
					h.xuehao += c[f][w];

				}

				h.map.put(f, h.xuehao);
				h.xuehao = "";
			}

			con.close();
		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
